﻿using DotNetDetour;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;

namespace HookDemo.HookHostCore
{
    public class ProcessHookService : IMethodHook
    {
        [HookMethod("HookDemo.TargetProcess.ProcessService", null, null)]
        public string GetProcessInfo()
        {
            return "这是HookDemo.HookHostProcess改写TargetClient 客户端 的GetProcessInfo 方法后得到的结果";
        }

        [OriginalMethod]
        public string GetProcessInfo_Original()
        {
            return null;
        }

        [HookMethod("HookDemo.TargetProcess.ProcessService", null, null)]
        public object GetProcessInfo([RememberType("HookDemo.TargetProcess.ProcessRequest", false)] object request)
        {
            var json = JsonSerializer.Serialize(request);
            var name = "这是HookDemo.HookHostProcess改写TargetClient 客户端的GetProcessInfo(obj)后得到的结果";
            return new ProcessResponse()
            {
                Name = name,
                Version = "改写的dll 版本"
            };
        }

        [OriginalMethod]
        public object GetProcessInfo_Original([RememberType("HookDemo.TargetProcess.ProcessRequest", false)] object request)
        {
            return null;
        }
    }
}